package com.itmuch.cloud.study.user.feign;

import com.itmuch.cloud.study.user.entity.User;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
/**
 * 方式一： 如果使用eurka则可以不配置url，只需要根据name就可以请求（eurka可以在注册中心找到对应的域名和端口）
 * 并且name值不区分大小写 @FeignClient(name = "MICROSERVICE-PROVIDER-USER")
 * 方式二： 如果不使用eurka则可以设置url的值为我们想要请求的目的地址，即可达到我们的要求
 * 例如@FeignClient(name = "microservice-provider-user", url = "http://localhost:8000")
 */
@FeignClient(name = "MICROSERVICE-PROVIDER-USER")
//@FeignClient(name = "microservice-provider-user", url = "http://localhost:8000")
public interface UserFeignClient {
  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  public User findById(@PathVariable("id") Long id);

  // 该请求不会成功
  @RequestMapping(value = "/get", method = RequestMethod.GET)
  public User get0(User user);

  @RequestMapping(value = "/get", method = RequestMethod.GET)
  public User get1(@RequestParam("id") Long id, @RequestParam("username") String username);

  @RequestMapping(value = "/get", method = RequestMethod.GET)
  public User get2(@RequestParam Map<String, Object> map);

  @RequestMapping(value = "/post", method = RequestMethod.POST)
  public User post(@RequestBody User user);
}
